/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kylingroup.Desktop.Plugin.FileUploader;

import com.kylingroup.Desktop.Plugin.FileUploader.KGPlugFileuploader;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

/**
 *
 * @author kylin
 */
public class Distribute extends Application{
    public Stage testFrame = null;
    private Group root = new Group();
    private BorderPane maincontent = null;
    private double maxwidth,maxheight,prewidth=1000,preheight=500;
            
    @Override
    public void start(Stage primaryStage) throws Exception {
        this.testFrame=primaryStage;
        
        Toolkit tk=Toolkit.getDefaultToolkit();
        Dimension screen=tk.getScreenSize();
        maxwidth=screen.getWidth();
        maxheight=screen.getHeight();

        testFrame.setScene(new Scene(createContent()));
        testFrame.centerOnScreen();
        testFrame.show();
        
    }
    
    public static void main(String[] args) {
        
        launch(args);
    }
    
    private Parent createContent(){
        FXMLLoader loader = new FXMLLoader();
        //InputStream in = Distribute.class.getResourceAsStream("Distribute.fxml");
        InputStream in = Distribute.class.getResourceAsStream("Fileuploader.fxml");
        loader.setBuilderFactory(new JavaFXBuilderFactory());
        //loader.setLocation(Distribute.class.getResource("Distribute.fxml"));
        loader.setLocation(Distribute.class.getResource("Fileuploader.fxml"));

        try {
            maincontent = (BorderPane) loader.load(in);
            maincontent.setMaxWidth(1366);
//            DistributeController maincontrol=(DistributeController)loader.getController();
//            
//            KGPlugFileuploader p=new KGPlugFileuploader();
//            p.install();
            
        } catch (IOException ex) {
            Logger.getLogger(Distribute.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
                Logger.getLogger(Distribute.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        root.getChildren().removeAll();
        root.getChildren().addAll(maincontent);
        return root;
    }
}
